<%--
  Created by IntelliJ IDEA.
  User: dj
  Date: 2018-08-31
  Time: 17:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ include file="/common/baseMeta.jsp" %>

    <link href="/static/js/layui/css/layui.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript" src="/static/js/dlcommon.js"></script>
    <script type="text/javascript" src="/static/js/layui/layui.all.js"></script>
    <script type="text/javascript" src="/static/js/common.js"></script>

    <title>病原体监测</title>
    <script type="text/javascript">

        var uid = "${sysStaffEntity.uid}";//唯一标识
        var lname = "${sysStaffEntity.lname}"; //登录工号
        $(function () {
            $("#l_datagrid").height(findDimensions_height() - 50);
            //初始化日期控件
            var date = $.getdate.getPresentDate();
            var now = new Date();
            now.addDays(-15);//加减日期操作	 
            $('#sdate').val(now.format("yyyy-MM-dd"));
            $('#edate').val(date);
            $.getJSON("/commapiV2", {p_dm: "Sys_Dictionary_Item_Get", dic_name: "院感染重点多重耐药菌"}, function (data) {
                if (data.success) {
                    $("#dcny").empty();
                    var option = "<option value=''></option>";
                    $(data.Table).each(function (index, row) {
                        option += "<option value='" + row.code + "'>" + row.name + "</option>";
                    });
                    $("#dcny").append(option);
                }
            }, true);
            $.getJSON("/commapiV2", {p_dm: "Sys_Dictionary_Item_Get", dic_name: "病原体的感染类型"}, function (data) {
                if (data.success) {
                    $("#grlx").empty();
                    var option = "<option value=''></option>";
                    $(data.Table).each(function (index, row) {
                        option += "<option value='" + row.code + "'>" + row.name + "</option>";
                    });
                    $("#grlx").append(option);
                }
            }, true);
            $.getJSON("/commapiV2", {p_dm: "sys_ks_Getzy", userid: lname}, function (data) {
                if (data.success) {
                    $('#ks').combobox({
                        data: data.Table,
                        valueField: 'code',
                        textField: 'name'
                    });
                }
            }, true);
            //初始化表头
            initGrid();
            LoadGrid();
            //是否显示处置单
            $.getJSON("/commapiV2", {p_dm: "Sys_Dictionary_Item_GetControl", item_code: 'c01'}, function (data) {
                if (data.success) {
                    if (data.Table[0].dic_name == '1') {
                        $("#btn_czb").show();
                    }
                    Else
                    {
                        $("#btn_czb").Hide();
                    }
                }
            }, true);

        })
        function LoadGrid() {
            //初始化数据
            $.getJSON("/commapiV2", {
                p_dm: "Thz_byxjg_getByt",
                sdate: $('#sdate').val(),
                edate: $('#edate').val(),
                dcny: $('#dcny').val(),
                ks: $('#ks').combobox('getText'),
                grlx: $('#grlx').val()
            }, function (data) {
                if (data.success) {
                    var griddata = {};
                    griddata.rows = data.Table;
                    griddata.total = data.totalcount;
                    $('#l_datagrid').datagrid('loadData', griddata);
                }
            }, true);
        }
        function initGrid() {
            $('#l_datagrid').datagrid({
                rownumbers: true,//显示行号
                singleSelect: true,//只显示一行
                fitColumns: true,
                sortable: true, //启用排序列
                collapsible: true,
                idField: 'id',
                columns: [
                    [
                        {
                            field: 'zyh', title: '住院号', width: '60px', align: 'center',
                            formatter: function (value, row, index) {
                                return '<a style="color:blue" href="/HzinfoDisplay/Hzinfo_sxt?blh=' + row.blh + '&zyh=' + row.zyh + '" target="view_frame">' + row.zyh + '</a>';
                            }
                        },
                        {field: 'hzxm', title: '患者姓名', width: '80px', align: 'center'},
                        {field: 'xb', title: '性别', width: '60px', align: 'center'},
                        {field: 'hznl', title: '患者年龄', width: '60px', align: 'center'},
                        {field: 'bbmc', title: '标本', width: '80px', align: 'center'},
                        {field: 'ryrq', title: '入院时间', width: '130px', align: 'center'},
                        {field: 'cysj', title: '送检时间', width: '130px', align: 'center'},
                        {field: 'bgsj', title: '报告时间', width: '130px', align: 'center'},
                        {field: 'sjks', title: '送检科室', width: '130px', align: 'center'},
                        {field: 'zgysname', title: '主管医生', width: '130px', align: 'center'},
                        {field: 'bytjg', title: '病原体', width: '130px', align: 'center'},
                        {field: 'dcny', title: '多重耐药', width: '130px', align: 'center'},
                        {field: 'grlx', title: '感染类型', width: '80px', align: 'center'},
                        {field: 'blh', title: '病例号', hidden: true},
                        {field: 'jyid', title: '检验号', hidden: true},
                        {field: 'jgid', title: '检验结果ID', hidden: true},
                        {field: 'zycs', title: '住院次数', hidden: true},
                        {field: 'id', hidden: true},
                        {field: 'sjkscode', hidden: true},
                    ]
                ]
            });
        }
        function Setgrlx() {
            var row = $('#l_datagrid').datagrid('getSelected');
            var url = "/FormApi?mobanId=e98b44f8-6e48-4d06-b101-d302857dd124&dataId=" + row.id;
            layeropen(800, 200, "设置感染类型", url);
        }
        function loadList() {
            LoadGrid();
        }
        function SendForm() {
            var row = $('#l_datagrid').datagrid('getSelected');
            var myDate = new Date();
            var fsrq = new Date(myDate);

            var postdata = {
                TDcny_CZD: {
                    KSNAME: row.sjks,
                    TXRQ: null,
                    HZXM: row.hzxm,
                    GLFJ: null,
                    ZYH: row.zyh,
                    BBMC: row.bbmc,
                    BHCS: null,
                    Fsrq: fsrq.format("yyyy年MM月dd日"),
                    TXR: null,
                    SJRQ: row.cysj,
                    YSNAME: row.zgysname,
                    JCSJ: null,
                    QTCS: null,
                    GLZL: null,
                    GLBS: null,
                    KSCODE: row.sjkscode,
                    ID: $.random.getGuid(),
                    DCNYMC: row.dcny,
                    JYID: row.jyid,
                    JGID: row.jgid
                }
            }
            //是否显示处置单
            $.getJSON("/commapiV2", {p_dm: "TDcny_CZD_Check", jyid: row.jyid, jgid: row.jgid}, function (data) {
                if (data.success) {
                    if (data.Table.length > 0) {
                        alert("处置单已经发送过了。");
                    }
                    else {
                        dLong.postajax("/commapiV2?p_dm=TDcny_CZD_Add", postdata, function (data) {
                            alert("发送成功");
                        })
                    }
                }
            }, true);
        }
    </script>
</head>
<body>
<div class="navheader form-inline" style="height:40px;margin-bottom: 0px;">
    <div class=" form-group">
        <label for="CYRQStart" style="padding:5px 10px 0 20px;">日期</label>

        <input type="text" class="form-control Wdate" style="width:100px;" name="sdate" id="sdate"
               placeholder=""
               value="${CYRQStart}"
               onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"/>
        <label for="CYRQEnd" style="padding:5px 10px 0 10px;">至</label>
        <input type="text" class="form-control Wdate" style="width:100px;" name="edate" id="edate"
               placeholder=""
               value="${CYRQEnd}"
               onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"/>
        <label for="ZYNumber" style="padding:5px 10px 0 20px;">送检科室</label>
        <select id="ks" class="easyui-combobox" style="height: 25px; width: 160px;">
        </select>
        <label for="ZYNumber" style="padding:5px 10px 0 20px;">感染类型</label>
        <select id="grlx"></select>
        <label for="ZYNumber" style="padding:5px 10px 0 20px;">多重耐药</label>
        <select id="dcny" style="width:160px"></select>
        <button type="button" class="btn btn-success bi-btn-search" onclick="LoadGrid()">
            <span class="glyphicon glyphicon glyphicon-search"></span>
        </button>
        <div class="btn-group-right">
            <div class="btn-group" role="group">
                <button type="button" class="btn layui-btn-warm bi-btn-width90" onclick="Setgrlx()">设置感染类型</button>
                <button type="button" class="btn layui-btn-danger bi-btn-width90" id='btn_czb' onclick="SendForm()">
                    发送处置表
                </button>
            </div>
        </div>

    </div>
</div>
<div style="width:100%;float:left;display:inline-block;padding-top:10px;">
    <table id="l_datagrid" class="datagrid" style="width:100%"></table>
</div>
</body>
</html>
